/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package bpel2rep.version.store.impl;

import java.util.Properties;

import bpel2rep.version.store.*;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;

import org.eclipse.emf.ecore.impl.EFactoryImpl;

import org.eclipse.emf.ecore.plugin.EcorePlugin;

import org.eclipse.emf.teneo.DataStore;
import org.eclipse.emf.teneo.PersistenceOptions;
import org.eclipse.emf.teneo.hibernate.HbDataStore;
import org.eclipse.emf.teneo.hibernate.HbHelper;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class StoreFactoryImpl extends EFactoryImpl implements StoreFactory {
	/**
	 * Creates the default factory implementation.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static StoreFactory init() {
		try {
			StoreFactory theStoreFactory = (StoreFactory)EPackage.Registry.INSTANCE.getEFactory("http://de.tiw.bpel2resp.version.store"); 
			if (theStoreFactory != null) {
				return theStoreFactory;
			}
		}
		catch (Exception exception) {
			EcorePlugin.INSTANCE.log(exception);
		}
		return new StoreFactoryImpl();
	}

	/**
	 * Creates an instance of the factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public StoreFactoryImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EObject create(EClass eClass) {
		switch (eClass.getClassifierID()) {
			case StorePackage.TENEO_STORE: return createTeneoStore();
			case StorePackage.DUMMY_STORE: return createDummyStore();
			default:
				throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public TeneoStore createTeneoStore() {
		final String dataStoreName = "bpel2rep";
		HbDataStore datastore = HbHelper.INSTANCE.createRegisterDataStore(dataStoreName);
		Properties props = new Properties();
		props.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
		props.setProperty("hibernate.connection.url", "jdbc:mysql://localhost/bpel2");
		props.setProperty("hibernate.connection.username", "root");
		props.setProperty("hibernate.connection.password", "");
		props.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
		props.setProperty("hibernate.max_fetch_depth", "1");
		// set joined strategy as joined subclass
		//props.setProperty(PersistenceOptions.INHERITANCE_MAPPING, "JOINED");
		// set lazy load false. 
		props.setProperty(PersistenceOptions.FETCH_CONTAINMENT_EAGERLY, "true");
		//props.setProperty(PersistenceOptions.USE_MAPPING_FILE, "true");
		datastore.setProperties(props);

		TeneoStoreImpl teneoStore = new TeneoStoreImpl(datastore);
		return teneoStore;                     
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DummyStore createDummyStore() {
		DummyStoreImpl dummyStore = new DummyStoreImpl();
		return dummyStore;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public StorePackage getStorePackage() {
		return (StorePackage)getEPackage();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @deprecated
	 * @generated
	 */
	@Deprecated
	public static StorePackage getPackage() {
		return StorePackage.eINSTANCE;
	}

} //StoreFactoryImpl
